#
# Cookbook Name:: installation_manager
# Recipe:: default
#
# Copyright 2013, IBM Corporation
#
# All rights reserved - Do Not Redistribute
#

# Installs Installation Manager

cuser = node[:chef][:user]
cgroup = node[:chef][:group]
inst_temp = node[:common][:inst_temp]+"/im"
  
directory "#{inst_temp}" do
  user cuser
  action :create
end

bash "fetch_im_install" do
  user cuser
  cwd inst_temp
  creates "/tmp/fetch_im_install.done"
  code <<-EOH
		set -e
		scp #{node[:common][:scp_repo]}/#{node[:im][:installer_path]} .
		sudo chmod -R a+r #{inst_temp}/
		touch /tmp/fetch_im_install.done
  EOH
end

bash "untar/uncompress install mgr package" do
  user cuser
  cwd inst_temp
  creates "#{inst_temp}/installc"
  code <<-EOH
  	unzip "$(basename #{node[:im][:installer_path]})"
  EOH
end

bash "install installation mgr package" do
  user cuser
  creates "/tmp/status_installed"
  cwd inst_temp
  code <<-EOH
    set -e
  	sudo ./installc -acceptLicense
  	touch /tmp/status_installed
  EOH
end
